<script lang="ts">
import {defineComponent, onMounted} from 'vue'
import * as echarts from 'echarts';
export default defineComponent({
  name: "LineCharts",
  setup() {
    onMounted(()=>{
      const pie = echarts.init(document.getElementById('pie'))
      window.addEventListener('resize', ()=>{
        pie.resize()
      })
      const option = {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          top: '5%',
          left: 'center'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 40,
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: 'Search Engine' },
              { value: 735, name: 'Direct' },
              { value: 580, name: 'Email' },
              { value: 484, name: 'Union Ads' },
              { value: 300, name: 'Video Ads' }
            ]
          }
        ]
      };
      pie.setOption(option);
    })
  }
})
</script>

<template>
  <h1>PieCharts-饼图</h1>

  <div id="pie"></div>
</template>

<style scoped lang="less">
#pie {
  height: 400px;
  width: 100%;
}
</style>
